home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / idl / nsIEditor.idl < prev    next >
Text File  |  2006-05-08  |  21KB  |  546 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * ***** BEGIN LICENSE BLOCK *****
  4.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  5.  *
  6.  * The contents of this file are subject to the Mozilla Public License Version
  7.  * 1.1 (the "License"); you may not use this file except in compliance with
  8.  * the License. You may obtain a copy of the License at
  9.  * http://www.mozilla.org/MPL/
  10.  *
  11.  * Software distributed under the License is distributed on an "AS IS" basis,
  12.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13.  * for the specific language governing rights and limitations under the
  14.  * License.
  15.  *
  16.  * The Original Code is the Mozilla browser.
  17.  *
  18.  * The Initial Developer of the Original Code is
  19.  * Netscape Communications, Inc.
  20.  * Portions created by the Initial Developer are Copyright (C) 1999
  21.  * the Initial Developer. All Rights Reserved.
  22.  *
  23.  * Contributor(s):
  24.  *   Daniel Glazman <glazman@netscape.com>
  25.  *   Akkana Peck <akkana@netscape.com>
  26.  *
  27.  * Alternatively, the contents of this file may be used under the terms of
  28.  * either of the GNU General Public License Version 2 or later (the "GPL"),
  29.  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  30.  * in which case the provisions of the GPL or the LGPL are applicable instead
  31.  * of those above. If you wish to allow use of your version of this file only
  32.  * under the terms of either the GPL or the LGPL, and not to allow others to
  33.  * use your version of this file under the terms of the MPL, indicate your
  34.  * decision by deleting the provisions above and replace them with the notice
  35.  * and other provisions required by the GPL or the LGPL. If you do not delete
  36.  * the provisions above, a recipient may use your version of this file under
  37.  * the terms of any one of the MPL, the GPL or the LGPL.
  38.  *
  39.  * ***** END LICENSE BLOCK ***** */
  40.  
  41. #include "nsISupports.idl"
  42. #include "domstubs.idl"
  43.  
  44. interface nsIURI;
  45. interface nsIAtom;
  46. interface nsISelection;
  47. interface nsISelectionController;
  48. interface nsIDocumentStateListener;
  49. interface nsIOutputStream;
  50. interface nsITransactionManager;
  51. interface nsITransaction;
  52. interface nsIEditorObserver;
  53. interface nsIEditActionListener;
  54. interface nsIInlineSpellChecker;
  55.  
  56. %{C++
  57. class nsIPresShell;
  58. class nsIContent;
  59. typedef short EDirection;
  60. %}
  61.  
  62.  
  63. [ptr] native nsIPresShellPtr(nsIPresShell);
  64. [ptr] native nsIContentPtr(nsIContent);
  65.  
  66. [scriptable, uuid(D4882FFB-E927-408b-96BE-D4391B456FA9)]
  67.  
  68. interface nsIEditor  : nsISupports
  69. {
  70. %{C++
  71.   typedef short EDirection;
  72. %}
  73.   const short eNone = 0;
  74.   const short eNext = 1;
  75.   const short ePrevious = 2;
  76.   const short eNextWord = 3;
  77.   const short ePreviousWord = 4;
  78.   const short eToBeginningOfLine = 5;
  79.   const short eToEndOfLine = 6;
  80.  
  81.   readonly attribute nsISelection selection;
  82.  
  83.   /**
  84.    * Init is to tell the implementation of nsIEditor to begin its services
  85.    * @param aDoc          The dom document interface being observed
  86.    * @param aPresShell    TEMP: The presentation shell displaying the document.
  87.    *                      Once events can tell us from what pres shell
  88.    *                      they originated, this will no longer be
  89.    *                      necessary, and the editor will no longer be
  90.    *                      linked to a single pres shell.
  91.    * @param aRoot         This is the root of the editable section of this
  92.    *                      document. If it is null then we get root
  93.    *                      from document body.
  94.    * @param aSelCon       this should be used to get the selection location
  95.    * @param aFlags        A bitmask of flags for specifying the behavior
  96.    *                      of the editor.
  97.    */
  98.   [noscript] void init(in nsIDOMDocument doc, in nsIPresShellPtr shell,
  99.                        in nsIContentPtr aRoot,
  100.                        in nsISelectionController aSelCon,
  101.                        in unsigned long aFlags);
  102.  
  103.   void setAttributeOrEquivalent(in nsIDOMElement element,
  104.                                 in AString sourceAttrName,
  105.                                 in AString sourceAttrValue,
  106.                                 in boolean aSuppressTransaction);
  107.   void removeAttributeOrEquivalent(in nsIDOMElement element,
  108.                                    in DOMString sourceAttrName,
  109.                                    in boolean aSuppressTransaction);
  110.  
  111.   /**
  112.    * postCreate should be called after Init, and is the time that the editor
  113.    * tells its documentStateObservers that the document has been created.
  114.    */
  115.   void postCreate();
  116.  
  117.   /**
  118.    * preDestroy is called before the editor goes away, and gives the editor a
  119.    * chance to tell its documentStateObservers that the document is going away.
  120.    */
  121.   void preDestroy();
  122.  
  123.   /** edit flags for this editor.  May be set at any time. */
  124.   attribute unsigned long flags;
  125.  
  126.   /**
  127.    * the MimeType of the document
  128.    */
  129.   attribute string contentsMIMEType;
  130.  
  131.   /** Returns true if we have a document that is not marked read-only */
  132.   readonly attribute boolean isDocumentEditable;
  133.  
  134.   /**
  135.    * the DOM Document this editor is associated with, refcounted.
  136.    */
  137.   readonly attribute nsIDOMDocument document;
  138.  
  139.   /** the body element, i.e. the root of the editable document.
  140.    */
  141.   readonly attribute  nsIDOMElement rootElement;
  142.  
  143.   /**
  144.    * the selection controller for the current presentation, refcounted.
  145.    */
  146.   readonly attribute nsISelectionController selectionController;
  147.  
  148.  
  149.   /* ------------ Selected content removal -------------- */
  150.  
  151.   /** 
  152.    * DeleteSelection removes all nodes in the current selection.
  153.    * @param aDir  if eNext, delete to the right (for example, the DEL key)
  154.    *              if ePrevious, delete to the left (for example, the BACKSPACE key)
  155.    */
  156.   void deleteSelection(in short action);
  157.  
  158.  
  159.   /* ------------ Document info and file methods -------------- */
  160.   
  161.   /** Returns true if the document has no *meaningful* content */
  162.   readonly attribute boolean documentIsEmpty;
  163.   
  164.   /** Returns true if the document is modifed and needs saving */
  165.   readonly attribute boolean documentModified;
  166.  
  167.   /** Sets the current 'Save' document character set */
  168.   attribute ACString documentCharacterSet;
  169.  
  170.   /** to be used ONLY when we need to override the doc's modification
  171.     * state (such as when it's saved).
  172.     */
  173.   void resetModificationCount();
  174.  
  175.   /** Gets the modification count of the document we are editing.
  176.     * @return the modification count of the document being edited.
  177.     *         Zero means unchanged.
  178.     */
  179.   long getModificationCount();
  180.  
  181.   /** called each time we modify the document.
  182.     * Increments the modification count of the document.
  183.     * @param  aModCount  the number of modifications by which
  184.     *                    to increase or decrease the count
  185.     */
  186.   void incrementModificationCount(in long aModCount);
  187.   
  188.   /* ------------ Transaction methods -------------- */
  189.  
  190.   /** transactionManager Get the transaction manager the editor is using.
  191.     */
  192.   readonly attribute nsITransactionManager transactionManager;
  193.  
  194.   /** doTransaction() fires a transaction.
  195.     * It is provided here so clients can create their own transactions.
  196.     * If a transaction manager is present, it is used.  
  197.     * Otherwise, the transaction is just executed directly.
  198.     *
  199.     * @param aTxn the transaction to execute
  200.     */
  201.   void doTransaction(in nsITransaction txn);
  202.  
  203.  
  204.   /** turn the undo system on or off
  205.     * @param aEnable  if PR_TRUE, the undo system is turned on if available
  206.     *                 if PR_FALSE the undo system is turned off if it
  207.     *                 was previously on
  208.     * @return         if aEnable is PR_TRUE, returns NS_OK if
  209.     *                 the undo system could be initialized properly
  210.     *                 if aEnable is PR_FALSE, returns NS_OK.
  211.     */
  212.   void enableUndo(in boolean enable);
  213.  
  214.   /** undo reverses the effects of the last Do operation,
  215.     * if Undo is enabled in the editor.
  216.     * It is provided here so clients need no knowledge of whether
  217.     * the editor has a transaction manager or not.
  218.     * If a transaction manager is present, it is told to undo,
  219.     * and the result of that undo is returned.  
  220.     * Otherwise, the Undo request is ignored and an
  221.     * error NS_ERROR_NOT_AVAILABLE is returned.
  222.     *
  223.     */
  224.   void undo(in unsigned long count);
  225.  
  226.   /** returns state information about the undo system.
  227.     * @param aIsEnabled [OUT] PR_TRUE if undo is enabled
  228.     * @param aCanUndo   [OUT] PR_TRUE if at least one transaction is
  229.     *                         currently ready to be undone.
  230.     */
  231.   void canUndo(out boolean isEnabled, out boolean canUndo);
  232.  
  233.   /** redo reverses the effects of the last Undo operation
  234.     * It is provided here so clients need no knowledge of whether
  235.     * the editor has a transaction manager or not.
  236.     * If a transaction manager is present, it is told to redo and the
  237.     * result of the previously undone transaction is reapplied to the document.
  238.     * If no transaction is available for Redo, or if the document
  239.     * has no transaction manager, the Redo request is ignored and an
  240.     * error NS_ERROR_NOT_AVAILABLE is returned.
  241.     *
  242.     */
  243.   void redo(in unsigned long count);
  244.  
  245.   /** returns state information about the redo system.
  246.     * @param aIsEnabled [OUT] PR_TRUE if redo is enabled
  247.     * @param aCanRedo   [OUT] PR_TRUE if at least one transaction is
  248.                               currently ready to be redone.
  249.     */
  250.   void canRedo(out boolean isEnabled, out boolean canRedo);
  251.  
  252.   /** beginTransaction is a signal from the caller to the editor that
  253.     * the caller will execute multiple updates to the content tree
  254.     * that should be treated as a single logical operation,
  255.     * in the most efficient way possible.<br>
  256.     * All transactions executed between a call to beginTransaction and
  257.     * endTransaction will be undoable as an atomic action.<br>
  258.     * endTransaction must be called after beginTransaction.<br>
  259.     * Calls to beginTransaction can be nested, as long as endTransaction
  260.     * is called once per beginUpdate.
  261.     */
  262.   void beginTransaction();
  263.  
  264.   /** endTransaction is a signal to the editor that the caller is
  265.     * finished updating the content model.<br>
  266.     * beginUpdate must be called before endTransaction is called.<br>
  267.     * Calls to beginTransaction can be nested, as long as endTransaction
  268.     * is called once per beginTransaction.
  269.     */
  270.   void endTransaction();
  271.  
  272.   void beginPlaceHolderTransaction(in nsIAtom name);
  273.   void endPlaceHolderTransaction();
  274.   boolean shouldTxnSetSelection();
  275.  
  276.   /** Set the flag that prevents insertElementTxn from changing the selection
  277.     * @param   should  Set false to suppress changing the selection;
  278.     *                  i.e., before using InsertElement() to insert
  279.     *                  under <head> element
  280.     * WARNING: You must be very careful to reset back to PR_TRUE after
  281.     *          setting PR_FALSE, else selection/caret is trashed
  282.     *          for further editing.
  283.     */
  284.   void setShouldTxnSetSelection(in boolean should);
  285.  
  286.   /* ------------ Inline Spell Checking methods -------------- */
  287.  
  288.   readonly attribute nsIInlineSpellChecker inlineSpellChecker;
  289.  
  290.   /* ------------ Clipboard methods -------------- */
  291.  
  292.   /** cut the currently selected text, putting it into the OS clipboard
  293.     * What if no text is selected?
  294.     * What about mixed selections?
  295.     * What are the clipboard formats?
  296.     */
  297.   void cut();
  298.  
  299.   /** Can we cut? True if the doc is modifiable, and we have a non-
  300.     * collapsed selection.
  301.     */
  302.   boolean canCut();
  303.   
  304.   /** copy the currently selected text, putting it into the OS clipboard
  305.     * What if no text is selected?
  306.     * What about mixed selections?
  307.     * What are the clipboard formats?
  308.     */
  309.   void copy();
  310.   
  311.   /** Can we copy? True if we have a non-collapsed selection.
  312.     */
  313.   boolean canCopy();
  314.   
  315.   /** paste the text in the OS clipboard at the cursor position, replacing
  316.     * the selected text (if any)
  317.     */
  318.   void paste(in long aSelectionType);
  319.  
  320.   /** Can we paste? True if the doc is modifiable, and we have
  321.     * pasteable data in the clipboard.
  322.     */
  323.   boolean canPaste(in long aSelectionType);
  324.  
  325.   /* ------------ Selection methods -------------- */
  326.  
  327.   /** sets the document selection to the entire contents of the document */
  328.   void selectAll();
  329.  
  330.   /** sets the document selection to the beginning of the document */
  331.   void beginningOfDocument();
  332.  
  333.   /** sets the document selection to the end of the document */
  334.   void endOfDocument();
  335.  
  336.    /* ------------ Drag/Drop methods -------------- */
  337.   
  338.    /** 
  339.     * canDrag decides if a drag should be started
  340.     * (for example, based on the current selection and mousepoint).
  341.     */
  342.   boolean canDrag(in nsIDOMEvent aEvent);
  343.  
  344.    /** 
  345.     * doDrag transfers the relevant data (as appropriate)
  346.     * to a transferable so it can later be dropped.
  347.     */
  348.   void doDrag(in nsIDOMEvent aEvent);
  349.  
  350.    /** 
  351.     * insertFromDrop looks for a dragsession and inserts the
  352.     * relevant data in response to a drop.
  353.     */
  354.   void insertFromDrop(in nsIDOMEvent aEvent);
  355.  
  356.   /* ------------ Node manipulation methods -------------- */
  357.  
  358.   /**
  359.    * setAttribute() sets the attribute of aElement.
  360.    * No checking is done to see if aAttribute is a legal attribute of the node,
  361.    * or if aValue is a legal value of aAttribute.
  362.    *
  363.    * @param aElement    the content element to operate on
  364.    * @param aAttribute  the string representation of the attribute to set
  365.    * @param aValue      the value to set aAttribute to
  366.    */
  367.   void setAttribute(in nsIDOMElement aElement, in AString attributestr,
  368.                     in AString attvalue);
  369.  
  370.   /**
  371.    * getAttributeValue() retrieves the attribute's value for aElement.
  372.    *
  373.    * @param aElement      the content element to operate on
  374.    * @param aAttribute    the string representation of the attribute to get
  375.    * @param aResultValue  [OUT] the value of aAttribute.
  376.    *                      Only valid if aResultIsSet is PR_TRUE
  377.    * @return              PR_TRUE if aAttribute is set on the current node,
  378.    *                      PR_FALSE if it is not.
  379.    */
  380.   boolean getAttributeValue(in nsIDOMElement aElement, 
  381.                             in AString attributestr, 
  382.                             out AString resultValue);
  383.  
  384.   /**
  385.    * removeAttribute() deletes aAttribute from the attribute list of aElement.
  386.    * If aAttribute is not an attribute of aElement, nothing is done.
  387.    *
  388.    * @param aElement      the content element to operate on
  389.    * @param aAttribute    the string representation of the attribute to get
  390.    */
  391.   void removeAttribute(in nsIDOMElement aElement, 
  392.                        in AString aAttribute);
  393.  
  394.   /**
  395.    * cloneAttribute() copies the attribute from the source node to
  396.    * the destination node and delete those not in the source.
  397.    *
  398.    * The supplied nodes MUST BE ELEMENTS (most callers are working with nodes)
  399.    * @param aAttribute    the name of the attribute to copy
  400.    * @param aDestNode     the destination element to operate on
  401.    * @param aSourceNode   the source element to copy attributes from
  402.    * @exception NS_ERROR_NULL_POINTER at least one of the nodes is null
  403.    * @exception NS_ERROR_NO_INTERFACE at least one of the nodes is not an
  404.    *                                  element
  405.    */
  406.   void cloneAttribute(in AString aAttribute,
  407.                       in nsIDOMNode aDestNode, in nsIDOMNode aSourceNode);
  408.  
  409.   /**
  410.    * cloneAttributes() is similar to nsIDOMNode::cloneNode(),
  411.    *   it assures the attribute nodes of the destination are identical
  412.    *   with the source node by copying all existing attributes from the
  413.    *   source and deleting those not in the source.
  414.    *   This is used when the destination node (element) already exists
  415.    *
  416.    * The supplied nodes MUST BE ELEMENTS (most callers are working with nodes)
  417.    * @param aDestNode     the destination element to operate on
  418.    * @param aSourceNode   the source element to copy attributes from
  419.    */
  420.   void cloneAttributes(in nsIDOMNode destNode, in nsIDOMNode sourceNode);
  421.  
  422.   /** 
  423.    * createNode instantiates a new element of type aTag and inserts it
  424.    * into aParent at aPosition.
  425.    * @param aTag      The type of object to create
  426.    * @param aParent   The node to insert the new object into
  427.    * @param aPosition The place in aParent to insert the new node
  428.    * @return          The node created.  Caller must release aNewNode.
  429.    */
  430.   nsIDOMNode createNode(in AString tag,
  431.                         in nsIDOMNode parent,
  432.                         in long position);
  433.  
  434.   /** 
  435.    * insertNode inserts aNode into aParent at aPosition.
  436.    * No checking is done to verify the legality of the insertion.
  437.    * That is the responsibility of the caller.
  438.    * @param aNode     The DOM Node to insert.
  439.    * @param aParent   The node to insert the new object into
  440.    * @param aPosition The place in aParent to insert the new node
  441.    *                  0=first child, 1=second child, etc.
  442.    *                  any number > number of current children = last child
  443.    */
  444.   void insertNode(in nsIDOMNode node,
  445.                   in nsIDOMNode parent,
  446.                   in long       aPosition);
  447.  
  448.  
  449.   /** 
  450.    * splitNode() creates a new node identical to an existing node,
  451.    * and split the contents between the two nodes
  452.    * @param aExistingRightNode   the node to split.
  453.    *                             It will become the new node's next sibling.
  454.    * @param aOffset              the offset of aExistingRightNode's
  455.    *                             content|children to do the split at
  456.    * @param aNewLeftNode         [OUT] the new node resulting from the split,
  457.    *                             becomes aExistingRightNode's previous sibling.
  458.    */
  459.   void splitNode(in nsIDOMNode existingRightNode,
  460.                  in long      offset,
  461.                  out nsIDOMNode newLeftNode);
  462.  
  463.   /** 
  464.    * joinNodes() takes 2 nodes and merge their content|children.
  465.    * @param aLeftNode     The left node.  It will be deleted.
  466.    * @param aRightNode    The right node. It will remain after the join.
  467.    * @param aParent       The parent of aExistingRightNode
  468.    *
  469.    *                      There is no requirement that the two nodes be
  470.    *                      of the same type.  However, a text node can be
  471.    *                      merged only with another text node.
  472.    */
  473.   void joinNodes(in nsIDOMNode leftNode,
  474.                  in nsIDOMNode rightNode,
  475.                  in nsIDOMNode parent);
  476.  
  477.   /** 
  478.    * deleteNode removes aChild from aParent.
  479.    * @param aChild    The node to delete
  480.    */
  481.   void deleteNode(in nsIDOMNode child);
  482.  
  483.   /** 
  484.    * markNodeDirty() sets a special dirty attribute on the node.
  485.    * Usually this will be called immediately after creating a new node.
  486.    * @param aNode      The node for which to insert formatting.
  487.    */
  488.   void markNodeDirty(in nsIDOMNode node);
  489.  
  490. /* ---------- direction controller ---------- */
  491.  
  492.   /** 
  493.    * Switches the editor element direction; from "Left-to-Right" to
  494.    * "Right-to-Left", and vice versa.
  495.    */
  496.   void switchTextDirection();
  497.  
  498. /* ------------ Output methods -------------- */
  499.  
  500.   /**
  501.    * Output methods:
  502.    * aFormatType is a mime type, like text/plain.
  503.    */
  504.   AString outputToString(in AString formatType,
  505.                          in unsigned long flags);
  506.   void outputToStream(in nsIOutputStream aStream,
  507.                       in AString formatType,
  508.                       in ACString charsetOverride,
  509.                       in unsigned long flags);
  510.  
  511.  
  512.   /* ------------ Various listeners methods -------------- */
  513.  
  514.   /** add an EditorObserver to the editors list of observers. */
  515.   void addEditorObserver(in nsIEditorObserver observer);
  516.  
  517.   /** Remove an EditorObserver from the editor's list of observers. */
  518.   void removeEditorObserver(in nsIEditorObserver observer);
  519.  
  520.   /** add an EditActionListener to the editors list of listeners. */
  521.   void addEditActionListener(in nsIEditActionListener listener);
  522.  
  523.   /** Remove an EditActionListener from the editor's list of listeners. */
  524.   void removeEditActionListener(in nsIEditActionListener listener);
  525.  
  526.   /** Add a DocumentStateListener to the editors list of doc state listeners. */
  527.   void addDocumentStateListener(in nsIDocumentStateListener listener);
  528.  
  529.   /** Remove a DocumentStateListener to the editors list of doc state listeners. */
  530.   void removeDocumentStateListener(in nsIDocumentStateListener listener);
  531.  
  532.  
  533.   /* ------------ Debug methods -------------- */
  534.  
  535.   /**
  536.    * And a debug method -- show us what the tree looks like right now
  537.    */
  538.   void dumpContentTree();
  539.  
  540.   /** Dumps a text representation of the content tree to standard out */
  541.   void debugDumpContent() ;
  542.  
  543.   /* Run unit tests. Noop in optimized builds */
  544.   void debugUnitTests(out long outNumTests, out long  outNumTestsFailed);
  545. };
  546.